﻿using LS.FrmUI.Dal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LS.FrmUI
{
    public partial class FrmModifyPwd : Form
    {
        public FrmModifyPwd()
        {
            InitializeComponent();
        }
        UserInfoDal dal = new UserInfoDal();
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNewPwd.Text))
            {
                MessageBox.Show("新密码必须填写。");
                return;
            }
            if (txtNewPwd.Text != txtRPwd.Text)
            {
                MessageBox.Show("两次密码不一致。");
                return;
            }
            bool b=dal.UpdateUserPwd(lblUserName.Text, txtRPwd.Text.Trim());
            if (b)
            {
                MessageBox.Show("修改密码成功，请牢记您的密码:"+txtRPwd.Text+"\r\n点击确定后重新登入系统。");
                Application.Restart();
            }
            else
            {
                MessageBox.Show("系统错误。修改失败。");
            }
        }

        private void FrmModifyPwd_Load(object sender, EventArgs e)
        {
            lblUserName.Text = setting.UserName;
        }
    }
}
